import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';

class plug_package_info extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return plug_package_info_state();
  }
}

class plug_package_info_state extends State<plug_package_info> {
  PackageInfo packageInfo;

  @override
  void initState()  {
    super.initState();
    PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
      setState(() {
        this.packageInfo = packageInfo;
      });
    });

  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("获取应用信息"),
        ),
        body: ListView(
          children: <Widget>[
            Text("appName--应用名称：${packageInfo.appName}"),
            Text("packageName--应用包名：${packageInfo.packageName}"),
            Text("version--应用版本名：${packageInfo.version}"),
            Text("buildNumber--应用版本号：${packageInfo.buildNumber}"),
          ],
        ),
      ),
    );
  }
}